<template>
  <div class="s-DataCenterlist">
    <div class="title-content">
      <div class="title">
        <span>{{ title }}</span>
      </div>
      <div class="more" v-if="moreUrl" @click="morePage">
        <span>更多</span>
        <i class="el-icon-arrow-right"></i>
      </div>
    </div>
    <div class="list-content">
      <template v-if="data && data.length > 0">
        <div class="item-content" @click="details" v-for="d in data" :key="d.id">
          <i></i>
          <div class="itemtitle">
            <p class="ell">{{ d.name }}</p>
            <div class="rightText">
              <span v-if="title == '最新资源'">{{ d.releasetime }}</span>
              <span class="visit" v-if="title == '热门资源'">{{ d.applysum }}次访问</span>
            </div>
          </div>
          <div class="work">{{ d.deptname }}</div>
        </div>
      </template>
      <el-empty v-else></el-empty>
    </div>
  </div>
</template>
<script setup>
import { inject } from "vue";
import { useRouter } from "vue-router";

const loginState = inject("loginState");
const route = useRouter();

const props = defineProps({
  data: Array,
  title: {
    type: String,
    default: "标题",
  },
  moreUrl: String,
});

const morePage = () => {
  loginState().then(() => {
    route.push({ path: "/DataDirectory" });
  });
};
const details = () => {
  loginState().then(() => {
    route.push({ path: "/DataDirectory" });
  });
};
</script>
